<include file="public@header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:url('room/index')}">所有班级</a></li>
			<li><a href="{:url('room/add')}">班级添加</a></li>
		</ul>
        <form class="well form-inline margin-top-20" method="get" action="{:url('Room/index')}">
            班级名称:
            <input type="text" class="form-control" name="room_name" style="width: 120px;" value="{:input('request.room_name/s','')}" placeholder="请输入班级名称">
            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn btn-danger" href="{:url('School/index')}">清空</a>
        </form>
		<table class="table table-hover table-bordered">
			<thead>
			<button class="btn btn-danger" onclick="delAll()" type="button">删除已选</button>
				<tr>
					<th width="16"><label><input type="checkbox" class="js-check-all"data-direction="x" data-checklist="js-check-x"></label></th>
					<th width="50">ID</th>
					<th>班级名称</th>
					<th>所属学校</th>
					<th>创建时间</th>
					<th width="180">{:lang('ACTIONS')}</th>
				</tr>
			</thead>
			<tbody>

				<foreach name="data" item="vo">
				<tr>
					<td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x"name="ids[]"
					value="{$vo.id}"></td>
					<td>{$key+1}</td>
					<td>{$vo.room_name}</td>
					<td>{$vo.school_name}</td>
					<td>{$vo.create_time}</td>
					<td>
							<a class="btn btn-xs btn-primary" href='{:url("room/edit",array("id"=>$vo["id"]))}'>{:lang('EDIT')}</a>
							<a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('room/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>

					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
		<div class="pagination">{$page}</div>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script src="__STATIC__/layui/layui.all.js"></script>
	<script>
		layui.use(['laydate','form'],function (){
		    var laydate = layui.laydate;
		    var form = layui.from;
			laydate.render({
				elem:'#start'
			});
			laydate.render({
				elem:'#end'
			});
			form.on('checkbox(checkall)',function(data){
			    if(data.elem.checked){
			        $('tbody input').prop('checked',true);
				}else{
			        $('tbody input').prop('checked',false);
				}
				form.render('checkbox')
			})
        })
		//多选删除
		function delAll(){
		   var ids = [];
		   //获取选中的id
			$('tbody input').each(function(index,el){
			    if($(this).prop('checked')){
			        ids.push($(this).val())
				}
			});
			layer.confirm('确认要删除吗?',function(index){
				//捉到所有被选中的，发异步进行删除
				$.ajax({
					url:"{:url('room/delAll')}",
					type:"post",
					data:{ids:ids},
					success:function (res){
					    if (res.code == 200){
					        layer.msg(res.msg,{icon:1});
					        setTimeout(function(){
					            location.reload();
							},1500);
						}else{
					        layer.msg(res.msg);
					        return false;
						}
					}
				})
			})
		}
	</script>>
</body>
</html>